package org.papervision3d.core.proto
{
    import flash.geom.*;
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.core.geom.Face3D;
    import org.papervision3d.core.geom.Mesh3D;
    import org.papervision3d.core.geom.DrawTriangle;

    public class RenderCallback extends TraverseCallback
    {
        protected var triangles:Array;

        public override function init(scene:SceneObject3D, camera:CameraObject3D, clip:Rectangle):void
        {
            triangles = new Array();
            return super.init(scene, camera, clip);
        }

        public override function face(face:Face3D, object:Mesh3D):void
        {
        	var triangle : DrawTriangle = face.drawtriangle;
        	
            if (inclip(triangle))// && face.isFrontCamera() )
                triangles.push(triangle);
           
        }

        public override function list():Array
        {
            triangles.sortOn("screenZ", Array.DESCENDING | Array.NUMERIC);

            return triangles;
        }

    }
}
